<?php
/**
 * AirportCode.php
 * 描述
 *
 * 作者:  胡毅 (huyi@comsenz.com)
 * 创建时间: 2012-10-13 下午12:03:13
 * 修改记录:
 *
 * $id$
 */

class Flight_Service_AirportCode extends Service {

    /**
     * _shardKey
     * 分库关键字
     *
     * @var array
     */
    protected $_shardKey;

    /**
     * __construct
     *
     * @param  array $shardKey
     * @return void
     */
    public function __construct($shardKey = array()) {

        $this->_shardKey = Service::convertProperty($shardKey);
    }

    /**
     * add
     * 添加通知到历史表
     *
     * @param array $data 通知数据

     * @return integer ID
     */
    public function add($data) {

        try {
            $threeCode = Flight_DAO_AirportCode::add($data, $this->_shardKey);
            return $threeCode;
        } catch (Exception $e) {
            Logger::error($e);
            throw new Service_Exception($e);
        }
    }

    /**
     * update
     * 更新一条历史记录
     *
     * @param $bnhid
     * @param $data
     * @return boolean
     */
    public function update($threeCode, $data) {

        try {
            $result = Flight_DAO_AirportCode::update($threeCode, $data, $this->_shardKey);
        } catch (Exception $e) {
            Logger::error($e);
            throw new Service_Exception($e);
        }

        return $result;
    }

    /**
     * get
     * 获取指定通知
     *
     * @param integer $bnhid
     * @param array $result
     */
    public function get($threeCode, $fields = array()) {

        try {
            $result = Flight_DAO_AirportCode::get($threeCode, $fields, $this->_shardKey);
        } catch (Exception $e) {
            Logger::error($e);
            throw new Service_Exception($e);
        }
        return $result;
    }

    /**
     * remove
     * 删除一条记录
     *
     * @param $bnhid
     * @param $data
     * @return boolean
     */
    public function remove($threeCode) {

        try {
            $result = Flight_DAO_AirportCode::remove($threeCode, $this->_shardKey);
        } catch (Exception $e) {
            Logger::error($e);
            throw new Service_Exception($e);
        }

        return $result;
    }
}